package org.hnxxxy.ebms.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.hnxxxy.ebms.common.Result;
import org.hnxxxy.ebms.service.TeacherAdmissService;
import org.hnxxxy.ebms.vo.TeacherAdmissVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author WANGWEI
 * @since 2021-06-10
 */
@RestController
@RequestMapping("/teacher-admiss")
public class TeacherAdmissController {

    @Autowired
    private TeacherAdmissService teacherAdmissService;

    @GetMapping("/get/{page}")
    @ApiOperation(value = "搜索老师地区")
    public Result<IPage<TeacherAdmissVo>> get(@PathVariable("page") int page){
        return teacherAdmissService.get(page);
    }

    @GetMapping("/getName/{name}/{page}")
    @ApiOperation(value = "根据老师姓名搜索")
    public Result<IPage<TeacherAdmissVo>> getName(@PathVariable("page") int page,@PathVariable("name") String name){
        return teacherAdmissService.getName(page,name);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加老师地区")
    public Result<String > add(@RequestBody TeacherAdmissVo admiss){
        return teacherAdmissService.add(admiss);
    }

    @PostMapping("/update")
    public Result<String> update(@RequestBody TeacherAdmissVo admiss){
        return teacherAdmissService.updateTeaAdmiss(admiss);
    }

    @DeleteMapping("/del/{id}")
    public Result<String> delById(@PathVariable("id") Integer id){
        return teacherAdmissService.del(id);
    }


}
